package acwing.lq.递归and递推;

import java.util.Scanner;

/**
 * @description:
 * @author: qian
 * @createDate: 2021/11/11
 */
public class 递归实现组合型枚举 {

    static int N = 30;
    static int n, m;
    static int[] way = new int[N];

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        dfs(0,0);
    }

    private static void dfs(int u, int start) {

     //   if (u + n - start < m) return;

        if (u == m ) {
            for (int i = 0; i < m; i++) {
                System.out.print(way[i] + " ");
            }
            System.out.println();
            return;
        }
        for (int i = start; i < n; i++) {

            way[u] = i + 1;
            dfs(u + 1, i + 1);
            way[u] = 0;
        }
    }
}
